package org.oop2.duotai;

public class FruitFactory {//水果工厂
    public Fruit sell(int money){
    	Fruit f = null;
    	switch(money){
    		case  1:
    			f = new Apple();
    			break;
    		case  2:
    			f = new Banana();
    			break;
    		default:
    			System.out.println("没有更贵的水果了");
    			break;
    	}
    	return f;
    }
    //对象也可以当做参数  --其作用类似与工厂实例
    public void buy(Fruit f){
    	f.eat();
    }
}
